import { request, HttpMethod, RequestConfig } from './request'
//个人概览组件相关操作

export const getNewestBPL = (patientUid: string | number) => {
  // console.log('参数是', patientUid);
  const config = <RequestConfig>{
    url: `/patient/persureHeartRate/getNewlyPressureData`,
    method: HttpMethod.GET,
    data: { patientUid: patientUid }
  }
  return request(config);
}

export const getDrugs = (patientUid: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/drugEatTime/getTodayDrugEatTime/${patientUid}`,
    method: HttpMethod.GET,
  }
  return request(config);
}

export const eatConfirm = (pepId: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/drugEatTime/eatDrug`,
    method: HttpMethod.POST,
    data: {
      pepId: pepId,
    }
  }
  return request(config);
}

export const getNewestTime = (patientUid: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/persureHeartRate/get_newest_time`,
    method: HttpMethod.GET,
    data: {
      patientUid: patientUid,
    }
  }
  return request(config);
}

export const getHeartRate = (patientUid: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/heartRateLogs/get_newly_heart_rate_data`,
    method: HttpMethod.GET,
    data: {
      patientUid: patientUid,
    }
  }
  return request(config);
}

// 获取某一天的心率平均值
export const getDailyAvgHeartRate = (data: Object) => {
  const config = <RequestConfig>{
    url: `/patient/heartRateLogs/daily_avg_heart_rate`,
    method: HttpMethod.GET,
    data: data
  }
  return request(config);
}

export const getAbnormalBPL = (patientUid: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/persureHeartRate/lastSevenDayAnomaly`,
    method: HttpMethod.GET,
    data: {
      patientUid: patientUid,
    }
  }
  return request(config);
}

// 最新步数（按用户）
export const getLatestStepCount = (patientUid: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/step-count/latest/${patientUid}`,
    method: HttpMethod.GET,
  }
  return request(config);
}

// 最新血氧饱和度（按用户）
export const getLatestBloodOxygen = (patientUid: string | number) => {
  const config = <RequestConfig>{
    url: `/patient/blood-oxygen/latest/${patientUid}`,
    method: HttpMethod.GET,
  }
  return request(config);
}

// 获取每日睡眠摘要
export const getDailySleepSummary = (data: { patientUid: string | number, date: string }) => {
  const config = <RequestConfig>{
    url: `/patient/sleep/dailySummary`,
    method: HttpMethod.GET,
    data: data
  }
  return request(config);
}